
function Vendor()
{
	this.fetchUrl="vendor";
	this.addUrl="add";
	this.addConfigLov="addLov";
	this.searchUrl="search";
}
function User()
{
	this.fetchUrl="user";
	this.addUrl="user/add";
}

Vendor.prototype = {
    fetch: function(config){
        alert(this.fetchUrl);
		alert(config.id);
    } ,
    add: function(config){
        console.log(config.dataType);
		config.url=this.addUrl;
		action.post(config);
    },
	search: function(config){
        console.log(config.dataType);
		config.url=this.searchUrl;
		action.post(config);
    },
	addLov: function(config){
        console.log(config.dataType);
		config.url=this.addConfigLov;
		action.post(config);
    }
};
function Action()
{
	this.error=function(obj){console.log('action error');};
	this.success=function(obj){
		console.log(obj.status);
		if(obj.status=='SUCCESS'){
			console.log(obj.objectName);
			console.log(obj.objectId);
			console.log(document.getElementById(obj.objectName).value);
			document.getElementById(obj.objectName).value=obj.objectId;
		}
	};
	this.complete=function(obj){console.log('action complete');};
}
Action.prototype = {
    post: function(config){
		alert(config.url);
        jQuery.ajax({
			url: config.url,
			data:config.data,
			type:'post',
			async: true,
			dataType: config.dataType,
			complete:this.complete,
			error:this.error,
			success:config.success
		});
    } ,
    get: function(config){
        jQuery.ajax({
			url: config.url,
			data:config.data,
			type:'GET',
			async: true,
			dataType: config.dataType,
			complete:config.complete,
			error:config.error,
			success:config.success
		});
    }
};

var vendor=new Vendor();
var action=new Action();

